package com.xiegang.apidriver.controller;

import com.xiegang.apidriver.service.VerificationCodeService;
import com.xiegang.internalcommon.dto.ResponseResult;
import com.xiegang.internalcommon.request.VerificationCodeDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xieGang
 * @description
 * @date 2023/4/3 13:35
 **/
@RestController
@Slf4j
public class VerificationCodeController {
    @Autowired
    private VerificationCodeService verificationCodeService;
    @GetMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDto verificationCodeDto){
        log.info("司机手机号："+verificationCodeDto.getDriverPhone());
        return verificationCodeService.checkAndSendVerificationCode(verificationCodeDto.getDriverPhone());
    }


    @PostMapping("/verificationCodeCheck")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDto verificationCodeDto){

        String driverPhone = verificationCodeDto.getDriverPhone();
        String verificationCode = verificationCodeDto.getVerificationCode();

        System.out.println("乘客手机号："+driverPhone+"，验证码："+verificationCode);

        return verificationCodeService.checkVerificationCode(driverPhone,verificationCode);
    }
}
